import { Route, Switch, Redirect } from "react-router-dom";
import { reducer, context, initState } from "./store";
import { useReducer } from "react";
import Login from "./pages/Login";
import NotFound from "./pages/NotFound";
import Layout from "./pages/Layout";
import "moment/locale/zh-cn";
import locale from "antd/lib/locale/zh_CN";
import { ConfigProvider } from "antd";

function App() {
	const store = useReducer(reducer, initState);

	return (
		<ConfigProvider locale={locale}>
			<context.Provider value={store}>
				<Switch>
					<Route path="/login" exact component={Login} />
					<Route path="/system" component={Layout} />
					<Redirect exact to="system" from="/" />
					<Route path="*" component={NotFound} />
				</Switch>
			</context.Provider>
		</ConfigProvider>
	);
}

export default App;
